<form<?php echo $this->getAttributeHtml()?>>
<?php
$tabs = $this->getTabs();
if(!empty($tabs)):
?>
<div class="form-tab">
<div class="navigate">
<ul>
<?php 
$isFirst = TRUE;
foreach ($tabs as $tab):
?>
<li><a<?php echo $isFirst? ' class="active"': ''?> href="#<?php echo $this->getId().'_'.$tab->getId()?>"><?php echo $tab->getLabel()?></a></li>
<?php
$isFirst = FALSE;
endforeach;?>
</ul>
</div>
<?php 
$isFirst = TRUE;
?>
    
<?php
foreach ($tabs as $tab):
?>
<div id="<?php echo $this->getId().'_'.$tab->getId()?>" class="tab-item<?php echo $isFirst? ' tab-active': ''?>">
<div class="title">
    <h4><?php echo $tab->getLabel() ?></h4>
</div>

<div class="tab-edit">
<table width="100%" align="center" cellpadding="0" cellspacing="1" border="0" class="pub-table edit">
<col width="20%">
<col width="80%">
<!--<thead>
<tr><td colspan="2">&nbsp;提示：带红<font color="red">*</font>号字段必须填写!</td>
</tr>
</thead>-->
<?php foreach($tab->getFields() as $fieldId):
    $fieldset = $this->getField($fieldId);
    $hiddenLabel = !strlen($fieldset->getLabel());
?>
<tr id="<?php echo $fieldId?>">
<td valign="top" class="field-label field-label-<?php echo $fieldset->getInput()->getType()?>"<?php echo $hiddenLabel? ' style="display:none"': ''?>>
<label id="<?php echo $fieldset->getId() ?>" class="field-<?php echo $fieldset->getInput()->getType()?>"<?php echo $fieldset->getStyleHtml()?>>
<span><?php if($fieldset->getRequired() == TRUE)
echo $fieldset->getLabel().'*';
else echo $fieldset->getLabel(); ?></span>
</label>
</td>
<td class="field-input field-edit-<?php echo $fieldset->getInput()->getType()?>">
<?php
if($fieldset->getRequired()):
	$fieldset->getInput()->addClass('required');
endif;
echo $fieldset->getInput()->toHtml();
?>
</td>

</tr>
<?php endforeach;
$isFirst = FALSE;
?>
</table>
</div>
</div>
<?php endforeach; ?>
<div class="clear"></div>
</div>
<script language="javascript" type="text/javascript">
$(function(){
    $('.navigate a').click(function(){
        $('.tab-item').hide();
        $('.navigate a').removeClass('active');
        var target = $(this).attr('href').replace('#', '');
        $('#' + target).show();
        $(this).addClass('active');
        return false;
    });
    Kdf.Ui.getForm('<?php echo $this->getId()?>').validateFail = function(form){
        $('.error').each(function(){
            if($(this).css('display') != 'none'){
                var tabId = $(this).parent().parent().parent().parent().parent().parent().attr('id');
                $('.tab-item').hide();
                $('#' + tabId).show();
                $('.navigate a').removeClass('active');
                $('a[href="#' + tabId + '"]').addClass('active');
                return false;
            }
        });
    }
});
</script>
<?php else: ?>

<table width="100%" align="center" cellpadding="0" cellspacing="1" border="0" class="pub-table edit">
<col width="20%">
<col width="80%">
<?php if($this->getTitle()):?>
<caption><label><?php echo $this->getTitle()?></label></caption>
<?php endif; ?>
<thead>
<tr><td colspan="2">&nbsp;提示：带红<font color="red">*</font>号字段必须填写!</td>
</tr>
</thead>
<?php foreach($this->getFields() as $fieldset): ?>
<tr>
<td align="right" class="field-label field-label-<?php echo $fieldset->getInput()->getType()?>">
<label id="<?php echo $fieldset->getId() ?>" class="field-<?php echo $fieldset->getInput()->getType()?>"<?php echo $fieldset->getStyleHtml()?>>
<span><?php if($fieldset->getRequired() == TRUE)
        echo '<font color=red>*</font>'.$fieldset->getLabel();
        else echo $fieldset->getLabel(); ?></span>
</label>
</td>
<td class="field-input field-edit-<?php echo $fieldset->getInput()->getType()?>">
<?php 
if($fieldset->getRequired()):
	$fieldset->getInput()->addClass('required');
endif;
echo $fieldset->getInput()->toHtml();
?>
</td>
<?php endforeach;?>
</table>
<?php endif; ?>
<?php
foreach($this->getHiddens() as $hidden):
    echo $hidden->toHtml();
endforeach;
?>
</form>